# -*- coding: utf-8 -*-
"""
@Author: 苏苏少年
@File: 漫画采集.py
@Time: 2022/4/16 21:03
"""

"""
    @@完整案例!!

"""

import requests

# 74
url = 'https://www.kanman.com/api/getchapterinfov2?product_id=1&productname=kmh&platformname=pc&comic_id=106345&chapter_newid=74&isWebp=1&quality=middle'


respones = requests.get(url)
# print(respones.text)


title = respones.json()['data']['current_chapter']['chapter_name']
num = 0

for img_url in respones.json()['data']['current_chapter']['chapter_img_list']:
    headers = {
        'referer': 'https://www.kanman.com/25935/1.html',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36'
    }

    res = requests.get(img_url,headers=headers)
    # print(res.content)
    with open('我本废材/' + title + str(num) + '.jpg','wb')as f:
        f.write(res.content)
        num += 1
        print('正在下载{} 第{}张'.format(title,num))





